package com.testplatfrom.autoapi.controller;


import com.testplatfrom.autoapi.domain.TestplatfromTree;
import com.testplatfrom.autoapi.domain.dto.tree.TestplatfromTreeAdd;
import com.testplatfrom.autoapi.domain.dto.tree.TestplatfromTreeUpdate;
import com.testplatfrom.autoapi.service.TestplatfromTreeService;
import com.testplatfrom.common.core.domain.R;
import com.testplatfrom.common.log.annotation.Log;
import com.testplatfrom.common.log.enums.BusinessType;
import com.testplatfrom.common.security.annotation.RequiresPermissions;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 杨森
 * @since 2023-12-11
 */
@RestController
@RequestMapping("/testplatfromTree")
public class TestplatfromTreeController {

    @Autowired
    private TestplatfromTreeService testplatfromTreeService;


    /**
     * 查询项目管理列表
     */
    @ApiOperation(value = "获取左侧树型结构", notes = "获取左侧树型结构")
    @RequiresPermissions("api:tree:list")
    @GetMapping("/tree")
    public R<TestplatfromTree> treeList() {
        return R.ok();
    }

    /**
     * 查询项目管理列表
     */
    @ApiOperation(value = "获取左侧树型结构", notes = "获取左侧树型结构")
    @RequiresPermissions("api:tree:add")
    @Log(title = "树型结构", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public R addTrre(@RequestBody @Valid TestplatfromTreeAdd testplatfromTreeAdd) {
        return R.ok(testplatfromTreeService.addTrre(testplatfromTreeAdd));
    }


    @ApiOperation(value = "获取左侧树型结构", notes = "获取左侧树型结构")
    @RequiresPermissions("api:tree:update")
    @Log(title = "树型结构", businessType = BusinessType.UPDATE)
    @PutMapping("/update")
    public R updateTrre(@RequestBody @Valid TestplatfromTreeUpdate testplatfromTreeUpdate) {
        return R.ok(testplatfromTreeService.updateTrre(testplatfromTreeUpdate));
    }

}

